from django import template
from decimal import Decimal, ROUND_HALF_UP
register = template.Library()

#自定义过滤器：价格四舍五入保留2位数小数
@register.filter('re_price')
def filter_price(content):
    return Decimal(content).quantize(Decimal('0.01'), rounding=ROUND_HALF_UP)